#include <54func.h>
int main(int argc, char *argv[])
{
    // ./10_myls_al dir1
    ARGS_CHECK(argc,2);
    DIR * dirp = opendir(argv[1]);
    ERROR_CHECK(dirp,NULL,"opendir");
    struct dirent * pdirent;
    while((pdirent = readdir(dirp)) != NULL){
        // 文件名->路径
        char path[1024] = {0};
        sprintf(path,"%s%s%s",argv[1],"/",pdirent->d_name);
        struct stat statbuf;
        int ret = stat(path,&statbuf);
        ERROR_CHECK(ret,-1,"stat");
        printf("%o %ld %d %d %ld %s %s\n", statbuf.st_mode,
                         statbuf.st_nlink,
                         statbuf.st_uid,
                         statbuf.st_gid,
                         statbuf.st_size,
                         ctime(&statbuf.st_mtime),
                         pdirent->d_name);
    }
    closedir(dirp);
    return 0;
}

